home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJGOS106.ARJ / TABLES.ASM < prev    next >
Assembly Source File  |  1992-04-13  |  4KB  |  192 lines

  1. ; This is file TABLES.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. ;    History:20,1
  16.     title    tables
  17.     .386p
  18.  
  19.     include    build.inc
  20.     include    segdefs.inc
  21.     include tss.inc
  22.     include gdt.inc
  23.     include idt.inc
  24.  
  25. ;------------------------------------------------------------------------
  26.  
  27.     start_data16
  28.  
  29.     extrn    _tss_ptr:word
  30.     extrn    _was_exception:word
  31.     extrn    _npx:byte
  32.  
  33.     public    _was_user_int
  34. _was_user_int    dw    0
  35.  
  36.     public    ivec_number
  37. ivec_number    db    ?
  38.  
  39. has_error    db    0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0
  40.  
  41.     end_data16
  42.  
  43. ;------------------------------------------------------------------------
  44.  
  45.     .286c
  46.     start_bss
  47.  
  48.     public    _gdt
  49. _gdt    label    gdt_s
  50.     db    type gdt_s * g_num dup (?)
  51.  
  52.     public    _idt
  53. _idt    label    idt_s
  54.     db    type idt_s * 256 dup (?)
  55.  
  56.     public    _i_tss
  57. _i_tss    label    tss_s
  58.     db    type tss_s dup (?)
  59.  
  60.     public    _v74_tss
  61. _v74_tss    label    tss_s
  62.     db    type tss_s dup (?)
  63.  
  64.     public    _v78_tss
  65. _v78_tss    label    tss_s
  66.     db    type tss_s dup (?)
  67.  
  68.     public    _v79_tss
  69. _v79_tss    label    tss_s
  70.     db    type tss_s dup (?)
  71.  
  72.     end_bss
  73.     .386p
  74.  
  75. ;------------------------------------------------------------------------
  76.  
  77.     start_code16
  78.  
  79. sound    macro
  80.     local    foo
  81.     mov    al,033h
  82.     out    061h,al
  83.     mov    cx,0ffffh
  84. foo:
  85.     loop    foo
  86.     endm
  87.  
  88. ivec    macro    n
  89.     push    ds
  90.     push    g_rdata
  91.     pop    ds
  92.     mov    ivec_number,n
  93.     pop    ds
  94.     db    0eah
  95.     dw    0, g_itss
  96.     endm
  97.  
  98.     public    _ivec0, _ivec1
  99. _ivec0:
  100.     ivec 0
  101. _ivec1:
  102.     x=1
  103.     rept 255
  104.      ivec x
  105.      x=x+1
  106.     endm
  107.  
  108.     public    _interrupt_common
  109. _interrupt_common:
  110.     cli
  111.     mov    bx,g_rdata
  112.     mov    ds,bx
  113.     mov    bx,_tss_ptr
  114.     mov    al,ivec_number
  115.     mov    [bx].tss_irqn,al
  116.     mov    esi,[bx].tss_esp
  117.     mov    fs,[bx].tss_ss        ; fs:esi -> stack
  118.     cmp    al,16
  119.     ja    has_no_error
  120.     mov    ah,0
  121.     mov    di,ax
  122.     cmp    has_error[di],0
  123.     je    has_no_error
  124.     mov    eax,fs:[esi]
  125.     mov    [bx].tss_error,eax
  126.     add    esi,4
  127. has_no_error:
  128.     mov    eax,fs:[esi]        ; eip
  129.     mov    [bx].tss_eip,eax
  130.     mov    eax,fs:[esi+4]
  131.     mov    [bx].tss_cs,ax
  132.     mov    eax,fs:[esi+8]
  133.     mov    [bx].tss_eflags,eax
  134.     add    esi,12
  135.     mov    [bx].tss_esp,esi    ; store corrected stack pointer
  136.     mov    _was_exception,1
  137.     jmpt    g_ctss            ; pass control back to real mode
  138.     cli
  139.     jmp    _interrupt_common    ; it's a task
  140.  
  141.     extrn    graphics_fault:near
  142.  
  143.     public    _page_fault
  144. _page_fault:
  145.     cli
  146.     mov    bx,g_rdata
  147.     mov    ds,bx
  148.     mov    es,bx
  149.     mov    eax,cr2
  150. if 1
  151.     cmp    eax,0e0000000h
  152.     jb    regular_pf
  153.     cmp    eax,0e0300000h
  154.     ja    regular_pf
  155.     jmp    graphics_fault
  156. regular_pf:
  157. endif
  158.     mov    bx,_tss_ptr
  159.     mov    [bx].tss_irqn,14    ; page fault
  160.     mov    [bx].tss_cr2,eax
  161.     pop    eax
  162.     mov    [bx].tss_error,eax
  163.     mov    eax,0
  164.     mov    cr2,eax            ; so we can tell INT 0D from page fault
  165.     mov    _was_exception,1
  166.     jmpt    g_ctss
  167.     jmp    _page_fault
  168.  
  169. v_handler    macro    label,vector
  170.     public    label
  171. label:
  172.     cli
  173.     mov    bx,g_rdata
  174.     mov    ds,bx
  175.     mov    es,bx
  176.     mov    bx,_tss_ptr
  177.     mov    [bx].tss_irqn,vector
  178.     mov    _was_exception,1
  179.     jmpt    g_ctss
  180.     jmp    label
  181.     endm
  182.  
  183.     v_handler    _v74_handler, 74h
  184.     v_handler    _v78_handler, 78h
  185.     v_handler    _v79_handler, 79h
  186.  
  187.     end_code16
  188.  
  189. ;------------------------------------------------------------------------
  190.  
  191.     end
  192.